package com.zhuss.core.area;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.zhuss.bean.bo.core.area.CreateAreaBo;
import com.zhuss.bean.bo.core.area.DeleteAreaBo;
import com.zhuss.bean.bo.core.area.UpdateAreaBo;
import com.zhuss.common.OperateService;
import com.zhuss.common.Processor;
import com.zhuss.exception.OceanException;

/**
 * @description: 地域操作的Service
 * @author: zhushanshuo
 * @create: Thu Apr 08 20:24:46 CST 2021
 **/
@Component("areaOperateService")
public class AreaOperateService implements OperateService<Void, Object> {
	
	@Autowired
	@Qualifier("areaCreate")
	private Processor<Object, CreateAreaBo> areaCreate;
	
	@Autowired
	@Qualifier("areaUpdate")
	private Processor<Object, UpdateAreaBo> areaUpdate;
	
	@Autowired
	@Qualifier("areaDelete")
	private Processor<Object, DeleteAreaBo> areaDelete;
	
	
	/**
	 * 创建
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
	public Void create(Object param) throws OceanException {
		
		CreateAreaBo bo = (CreateAreaBo) param;
		
		areaCreate.process(bo);
		
		return null;
	}
    
	/**
	 * 修改
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
    public Void update(Object param) throws OceanException {
    	
		UpdateAreaBo bo = (UpdateAreaBo) param;
		
		areaUpdate.process(bo);
		
    	return null;
    }
	
	/**
	 * 删除
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public Void delete(Object param) throws OceanException {
		
		DeleteAreaBo bo = (DeleteAreaBo) param;
		
		areaDelete.process(bo);
		
		return null;
	}
	
}

